package com.edu.gdkm.servlet.ticket;

import com.edu.gdkm.dao.dypDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/removeServlet")
public class removeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String back = req.getParameter("back");
        String stored = req.getParameter("stored");
        String oid = req.getParameter("id");
        try {
            dypDao dao = new dypDao();
            dao.delStored(stored, oid);
            dao.close();
        } catch (SQLException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        // 刷新
        resp.sendRedirect(req.getContextPath()+back);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
